// JavaScript Document
$(document).ready(function() {
	function moreDemo(org){
			var _this = this;
			_this.moreBox = org.moreBox,//父级层
			_this.moreList = org.moreList,//列表的层
			_this.moreButton = org.moreButton,//更多按钮
			_this.moreSelect = org.moreSelect,//选中项
			_this.moreBLi = org.moreBLi,//更多的li
			_this.hiddenH = org.hiddenH,//隐藏高度
			_this.classHover =org.classHover;//样式切换
			var moreListH = _this.moreList.height();
			//判断是否显示更多
			if(moreListH>27){
			_this.moreBLi.show();
			}else{
				_this.moreBLi.show();
				};
			
			//通过选中项判断是否展开
			
			var moreSelecttop = _this.moreSelect.offset().top,
			moreBlitop = _this.moreBLi.offset().top;
			if(moreSelecttop>moreBlitop){
				_this.moreBox.css("height",moreListH);
				_this.moreBLi.addClass(_this.classHover);
				};
			//判断收起展开
			_this.moreButton.click(function(){
				_this.moreBox.css("height",moreListH);
				if(_this.moreBLi.hasClass(_this.classHover)){
					_this.moreBLi.removeClass(_this.classHover);
					_this.moreBox.css("height",_this.hiddenH);
					}else{
						_this.moreBLi.addClass(_this.classHover);
						};
				});
	};
	//判断盒子模型居中
	function margin_auto(org){
		var _this = this;
			_this.box = org.box,//父级box
			_this.list = org.list,//子元素的
			_this.listother = org.listother,//子元素margin,padding
			_this.otherW = org.otherW;//其他宽度
		var list_num = _this.list.length,//子元素个数
			list_width = _this.list.width()+_this.listother,//子元素实际所占用宽度
			box_width = list_num*list_width+_this.otherW;//父级实际占用宽度
			_this.box.css("width",box_width);//赋值
	};
	//判断底部导航是否显示,选中全部和其他是显示
	(function(){
		var all_btm = $(".con_box .con_left .con_listC ul li[date='all_btm']"),
			other_btm = $(".con_box .con_left .con_listC ul li[date='other_btm']"),
			btm_nav = $("#bottom_pd ul.all"),
			btm_navother = $("#bottom_pd div.only_ot");
			if(all_btm.hasClass("on")||other_btm.hasClass("on")){
				btm_nav.show();
				}else{
					btm_nav.hide();
					};
	})();
	
	new moreDemo({
		moreBox:$(".con_box .con_left .con_listC .more_box"),
		moreList:$(".con_box .con_left .con_listC .more_box ul.index_list"),
		moreButton:$(".con_box .con_left .con_listC .more_box ul.index_list li span a"),
		moreSelect:$(".con_box .con_left .con_listC .more_box ul.index_list li.on"),
		moreBLi:$(".con_box .con_left .con_listC .more_box ul.index_list li.rit"),
		hiddenH:20,
		classHover:"up"
	});
	
	new margin_auto({
		box:$("#bottom_pd ul.all"),
		list:$("#bottom_pd ul.all li"),
		listother:10,
		otherW:0
		})
	new margin_auto({
		box:$("#bottom_pd .only_ot ul.lettle"),
		list:$("#bottom_pd .only_ot ul.lettle li[date='btm_list']"),
		listother:6,
		otherW:20
		})
	
});